package Proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

//Handler，由这个Handler处理器来接替proxy做实际工作。
public class PersonHandler implements InvocationHandler {
    public Object realObject = null;

    public PersonHandler(Object realObject) {

        this.realObject = realObject;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("吃饭前要洗手。。。。");
        method.invoke(realObject, args);
        System.out.println("吃饭后要洗碗。。。。");
        return null;
    }

}
